#pragma once
#include "includeBase.h"

#include "GraphicsBox.h"
#include "MainStatusBarManager.h"

class AppGraphicsScene : public QGraphicsScene
{
    Q_OBJECT
public:
    explicit AppGraphicsScene(QObject* parent = nullptr);
    ~AppGraphicsScene() override;

public:
    void clearRectItems();
    void setupRectItems(int count);
    void updateRectItemsPos(const vector<QRect>& rects);
    vector<QRect> getRects() const;
    void updateScaleRate(double rate);

public: // QGraphicsScene overrides
    void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
    void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
    void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
    bool updateRectItem(const QPointF& pos, bool released = false);

private:
    void setupRectItem(int index);

private:
    bool isMousePressed_;
    QPointF startPos_;
    QRectF selectedRect_;
    vector<GraphicsBox*> rectItems_;
    int selectedRectIndex_;
};
